/**
 * 点击防抖指令
 */
export default {
    mounted(el, binding, vnode) {
        if (typeof binding.value !== "function") {
            throw "指令值必须是函数";
        }
        let timer = null;
        const delay = parseInt(binding.arg) || 500;
        const handler = binding.value;
        el.addEventListener(
                "click",
                () => {
                    clearTimeout(timer);
                    timer = setTimeout(() => {
                        handler();
                    }, delay);
                },
                { passive: false }
        );
    }
}
